/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using System.Collections;

namespace EXtremecode.Common
{
	/// <summary>
	/// Summary description for CacheRepository.
	/// </summary>
	public class CacheRepository
	{
		private Hashtable cache=new Hashtable();
		private static CacheRepository singleton=new CacheRepository();
		CacheRepository(){}
		public static CacheRepository Instance
		{
			get
			{
				if(singleton==null)
				{
					singleton=new CacheRepository();
				}
				return singleton;
			}
		}
		public ICachedDataSet CachedDataSet
		{
			get
			{
				return this["CachedDataSet"] as ICachedDataSet;
			}
			set
			{
				this["CachedDataSet"]=value;
			}
		}
		public object this[string key]
		{
			get
			{
				return	cache["CacheRepository_" + key];
			}
			set
			{
				if(cache["CacheRepository_" + key]==null)
				{
					cache.Add("CacheRepository_" + key,value);
				}
				else
				{
					cache["CacheRepository_" + key]=value;
				}
			}
		}
	}
}
